package com.lanou3g.hw0412;


public class OperatorFctory {
    // 根据操作符(+-/*)
    // 来生成 指定的 计算类
    // 工厂模式
    public static Operator getOperator(String op) {
        Operator operator = null;
        switch (op) {
            case "+":
                operator = new OpAdd();
                break;
            case "-":
                operator = new OpSub();
                break;
            case "*":
                operator = new OpMultiply();
                break;
            case "/":
                operator = new OpDivide();
                break;
            case "^":
                operator = new OpPower();
                break;
        }
        return operator;
    }
}
